package com.orhon.smartcampus.modules.user.entity;


import java.util.Date;

import javax.persistence.*;

import com.orhon.smartcampus.modules.student.entity.SInformation;
import com.orhon.smartcampus.modules.teacher.entity.TInformation;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.orhon.smartcampus.modules.base.entity.Schools;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;


@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "user_users")
public class Users {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "username")
    private String username;

    @Column(name = "password")
    private String password;

    @Column(name = "email")
    private String email;

    @Column(name = "status")
    private Integer status;

    @Column(name = "idcard")
    private String idCard;

    @OneToOne( cascade = CascadeType.ALL , fetch = FetchType.LAZY)
    @JoinColumn(name = "school_id", referencedColumnName = "id")
    @NotFound(action= NotFoundAction.IGNORE)
    @Fetch(FetchMode.JOIN)
    private Schools school;

    @Column(name = "last_login_ip")
    private String last_login_ip;  //"上次登录ip"'

    @Column(name = "last_login_time")
    private String last_login_time;  //"上次登录时间"

    @Column(name = "remember_token")
    private String remember_token;

    @Column(name = "api_token")
    private String api_token;  //"api token"

    @Column(name = "created_at")
    private Date created_at;  //"创建时间"

    @Column(name = "updated_at")
    private Date updated_at;  //"更新时间"

    @Column(name = "deleted_at")
    private Date deleted_at;

    @Column(name = "user_type")
    private String user_type;  //"用户类型（admin/teacher/student/other/parent）"

    @Column(name = "system_lang")
    private String system_lang;

    @Column(name = "mobile")
    private String mobile;

    @Column(name = "equipment_id")
    private String equipment_id;

    @Column(name = "unionid")
    private String unionid;

    @Transient
    private String name;

  //学段
//  	@ManyToMany(fetch = FetchType.LAZY)
//  	@JoinTable(name = "base_subject_period_relation",
//  	joinColumns = { @JoinColumn(name = "subject_id")}, 
//  	inverseJoinColumns = { @JoinColumn(name = "period_id")})
//  	List<Periods> periods;
//
//
//  	//年级
//  	@ManyToMany(fetch = FetchType.LAZY)
//  	@JoinTable(name = "base_subjects_grade_relation",
//  	joinColumns = { @JoinColumn(name = "subject_id")}, 
//  	inverseJoinColumns = { @JoinColumn(name = "grade_id")})
//  	List<Grades> grades;


//    @Override
//    public String toString() {
//        return "Users{" +
//                "id=" + id +
//                '}';
//    }
}
